package com.ganbo.ms.java8.sort;


import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Data
public class Person {

    private int id;
    private String name;

    public Person(String name) {
        this.name = name;
    }

    public Person(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public Person() {
    }

    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
        list.add(new Person(1, "aaa"));
        list.add(new Person(6, "bbb"));
        list.add(new Person(5, "ccc"));
        list.add(new Person(7, "ddd"));

        Comparator<Person> comparator = Comparator.comparingInt(Person::getId);
        list.sort(comparator);
        System.out.println(list);


    }
}
